package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.client.*;
import com.acme.bankapp.exception.bank.*;

import java.io.*;

public class BankApplication {

    public static ClientRegistrationListener listeners[] = new ClientRegistrationListener[3];

    private static Bank bank = new Bank(listeners);


    public static void main(String[] args) throws BankException, IOException {

        String
                path = "";

        if (args.length == 2) {
            switch (args[0]) {
                case "-loadbank":
                    path = args[1];
                    break;
                default:
                    System.out.printf("Invalid arguments\n");
            }
        }

        listeners[0] = new Bank.PrintClientListener();
        listeners[1] = new Bank.EmailNotificationListener();
        listeners[2] = new Bank.DebugListener();

        try {
            BankService.readBank(bank, path);
            BankService.addClient(bank, new Client("Petrov Kolya", Gender.Male, 3.56, 32.3, 46.52));
            BankService.saveBank(bank, path);
        } catch (Exception e) {
            System.out.printf("Exception: %s\n", e.getMessage());
        }

    }

}